package Java.BlackHorse.Map.HashMap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;

public class HashMapDemo1 {
    public static void main(String[] args) {

        Map<Student,String> hm = new HashMap<>();

        Student s1 = new Student("zhangsan",23);
        Student s2 = new Student("wangwu",19);
        Student s3 = new Student("lisi",20);

        hm.put(s1,"河南");
        hm.put(s2,"河北");
        hm.put(s3,"山东");

        Set<Student> keys = hm.keySet();
        for(Student key:keys){
            String value=hm.get(key);
            System.out.println(key+":"+value);
        }

        System.out.println("----------");

        hm.forEach(new BiConsumer<Student, String>() {
            @Override
            public void accept(Student student, String s) {
                System.out.println(student+":"+s);
            }
        });

       hm.forEach((Student student, String s)-> System.out.println(student+":"+s));

    }
}
